package com.lfm.improve_;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;

public class GenericDetail {
    public static void main(String[] args) {
        //1.
        //只能是引用类型
        //HashMap<int, int> hashMap = new HashMap<int, int>();
        //HashMap<Integer, Integer> hashMap = new HashMap<Integer, Integer>();


        //2.在给泛型制定类型后，可以传入该类型或者其子类类型
        HashSet<A> as = new HashSet<A>();
        B b = new B();
        as.add(b);


        //3. 开发一般简写:
        HashSet<String> strings = new HashSet<>();
        //4. 如果是这样写 泛型默认是Object
        ArrayList list = new ArrayList();
        /*
            public boolean add(E e) {
                ....
            }
         */
        Tiger tiger = new Tiger();

    }
}
class Tiger<E> {//类
    E e;

    public Tiger() {}
    public Tiger(E e) {
        this.e = e;
    }
}
class A{}
class B extends A{}
